package com.example.starapp.luckfrag;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import com.animee.starapp.starfrag.StarInfo;
import java.util.List;
/**
 * 运势界面的fragment
 */
import com.example.starapp.R;
import com.example.starapp.utils.AssetsUtils;

public class LuckFragment extends Fragment {
    GridView luckGV;
    private LuckBaseAdapter luckBaseAdapter;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_luck, container, false);
        luckGV = view.findViewById(R.id.luck_gv);
//        加载数据
        initGrid();
        return view;
    }
    /*生成九宫格当中的数据*/
    private void initGrid() {
//        获取activity传递过来的数据
        Bundle bundle = getArguments();
        StarInfo starInfo = (StarInfo) bundle.getSerializable("info");
        List<StarInfo.StarinfoBean> list = starInfo.getStarinfo();  //数据源
//        创建适配器
        luckBaseAdapter = new LuckBaseAdapter(getContext(), list);
//        设置适配器
        luckGV.setAdapter(luckBaseAdapter);
    }
}